<?php

namespace addons\csmitsm\library\xcore\xcore\utils;

use DateTime;

class XcDateUtils
{
    /**
     * 
        getDateArray(3, 1) 
        如果当前日期为 2024-12-29 , 则返回数组["2024-12-26","2024-12-27","2024-12-28","2024-12-29","2024-12-30"]
     * @return array
     */
    public static function getDateArraysFromRangeDays($beginDays, $endDays)
    {
        $dateArray = [];

        $currentDate1 = new DateTime();
        $currentDate2 = new DateTime();

        $startDate = $currentDate1->modify("-{$beginDays} day");
        $endDate = $currentDate2->modify("+{$endDays} day");

        for ($date = clone $startDate; $date <= $endDate; $date->modify('+1 day')) {
            $dateArray[] = $date->format('Y-m-d');
        }

        return $dateArray;
    }
    

    
}
